//
//  MeatMineHeader.m
//  PigMarket
//
//  Created by 张敬 on 2019/7/30.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "MeatMineHeader.h"

@interface MeatMineHeader ()

@property (nonatomic, strong) UIView *contentView;

@property (nonatomic, strong) UIImageView *shopIcon;

@property (nonatomic, strong) UILabel *nickLab;

@property (nonatomic, strong) UILabel *signatureLab;


@end


@implementation MeatMineHeader

#pragma mark - lifecycle methods

- (void)setupUI{
    
    self.backgroundColor = mBackgroudColor;
    self.height = 125;
    
    [self addSubview:self.contentView];
    
    self.line.hidden = NO;
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 110-1, KScreenWidth, 1)];
    self.line.path = path.CGPath;
    [_contentView.layer addSublayer:self.line];
    
    [_contentView addSubview:self.shopIcon];
    [_contentView addSubview:self.nickLab];
    [_contentView addSubview:self.signatureLab];

}

- (void)setupLayout{
    
    {
        _contentView.size = CGSizeMake(KScreenWidth - 30, 110);
        _contentView.mj_x = 15;
        _contentView.mj_y = 15;
    }
    
    {
        _shopIcon.size = CGSizeMake(70, 70);
        _shopIcon.mj_x = 20;
        _shopIcon.mj_y = 20;
    }
    
    {
        _nickLab.mj_x = _shopIcon.right + 20;
        _nickLab.size = CGSizeMake(KScreenWidth - _nickLab.left - 90, 28);
        _nickLab.mj_y = 29;
    }
    
    {
        _signatureLab.size = CGSizeMake(_nickLab.width, 16);
        _signatureLab.mj_x = _nickLab.mj_x;
        _signatureLab.mj_y = _nickLab.bottom + 6;
    }
}


#pragma mark - response methods
#pragma mark - public methods
#pragma mark - setter methods


#pragma mark - getter methods

- (UIView *)contentView{
    
    if (!_contentView) {
        _contentView = [[UIView alloc] init];
        _contentView.backgroundColor = KWhiteColor;
        [self drawCornerByView:_contentView];
    }
    return _contentView;
}


- (void)drawCornerByView:(UIView *)view{
    
    CGRect rect = CGRectMake(0, 0, KScreenWidth - 30, 110);
    UIRectCorner corners = UIRectCornerTopLeft|UIRectCornerTopRight;
    UIBezierPath *rounded = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:corners cornerRadii:CGSizeMake(8, 8)];
    CAShapeLayer *shape = [[CAShapeLayer alloc] init];
    [shape setPath:rounded.CGPath];
    view.layer.mask = shape;
}


- (UIImageView *)shopIcon{
    if (!_shopIcon) {
        _shopIcon = [UIImageView new];
        _shopIcon.image = [UIImage imageNamed:@"meat_shop_Icon"];
        [self addShadowAndCircleCorner:_shopIcon.layer corner:35];
    }
    return _shopIcon;
}


- (UILabel *)nickLab{
    
    if (!_nickLab) {
        _nickLab = [UILabel makeLabelWithText:@"昵称昵称" textColor:UIColorFromRGB(0x333333) font:mFont(20) textAliment:0];
    }
    return _nickLab;
}


- (UILabel *)signatureLab{
    
    if (!_signatureLab) {
        _signatureLab = [UILabel makeLabelWithText:@"个性签名～～～～～～～～ " textColor:UIColorFromRGB(0x808080) font:mFont(13) textAliment:0];
    }
    return _signatureLab;
}


@end
